package pkg.filter;

import com.googlecode.objectify.Objectify;
import com.googlecode.objectify.Query;
import java.util.ArrayList;
import java.util.List;
import pkg.dao.Filter;
import pkg.entity.Teacher;

public class TeacherFilter extends Filter {
    Boolean primary;

    @Override
    public List getElements(Objectify ofy) {
        Query<Teacher> query = ofy.query(Teacher.class);

        if (primary != null) {
            query.filter("primary", primary);
        }

        if (getSortColumn() != null) {
            query.order(getSortColumn());
        }

        List<Teacher> entities = new ArrayList<Teacher>();
        for (Teacher e : query) {
            entities.add(e);
        }
        return entities;
    }

    @Override
    public int getCount(Objectify ofy) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void setSimple(String filterText) {
        throw new UnsupportedOperationException("Not yet implemented");
    }

    public void setPrimary(Boolean b) {
        this.primary = b;
    }

}
